package com.cdj.common.util;

import android.content.Context;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;

/**
 * ---------------------------------------------------------<br />
 * desc：<br />
 * author：Darren Chen <br />
 * date：2020/9/2<br />
 * email：darren.chen@zeasn.com<br />
 * ---------------------------------------------------------<br />
 */
public class SpannableUtil {

    public static SpannableString getSpannable(Context context, String price, int size){
        // 设置文本字体大小不一样的文本
        SpannableString beforeDp = new SpannableString(price);
        beforeDp.setSpan(new AbsoluteSizeSpan((int) DisplayMetricsUtil.dipToPixel(context, size)), 0, "￥".length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        beforeDp.setSpan(new AbsoluteSizeSpan(DisplayMetricsUtil.dipToPixel(context, size)), price.indexOf("."),price.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return beforeDp;
    }

}
